package lab6part1;

/**
 * Title: Part1 class for CSIS 235 Lab #6
 * Description: CS 235 Lab #6 - Part1
 *              This class has a main method and is the
 *              client of the Player and Pile classes.
 * @author 
 * @email  your.n.here@my.uwrf.edu
 * @date   
 */

public class Part1 {

	/**
	 * main - this is where the Part1 program starts
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Pile pile = new Pile( 10 );
		System.out.println("Number of stick in the pile is " + pile.sticks());
		
		Player phil  = new Player("Phil");
		Player edith = new Player("Edith");
		System.out.println("The players are: " + phil + " and " + edith);
		System.out.println("\n");
		
		int turn = 0;
		int lastplayer = turn;
		while(pile.sticks()>=0){
			// Phil's turn
			System.out.println(" --> " + phil );
			phil.takeTurn(pile);
			lastplayer = turn;
			
			if (pile.sticks()== 0)
				break;

			// Edith's turn
			turn = (turn + 1 ) % 2;
			lastplayer = turn;			
			System.out.println(" --> " + edith );
			edith.takeTurn(pile);
		}
		
		System.out.print("Last player was ");
		if (turn == 0)
			System.out.println( phil);
		else
			System.out.println( edith);
	}
}